/**
 * 
 */
package com.p2p.base.model;

import java.io.Serializable;

/**
 * @author ruiqi
 *
 */
@Deprecated
public abstract class AbstractPagination implements Serializable {

	private static final long serialVersionUID = -2586928223918655157L;

	public static final String DIRECTION_DESC = "DESC";
	public static final String DIRECTION_ASC = "ASC";
	
	private int start;
	private int limit = 10;

	private String sort;

	private String dir;

	private boolean needCount;

	private int totalCount;

	public final int getTotalCount() {
		return this.totalCount;
	}

	public final void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}

	public final void calStart() {
		if (this.start >= this.totalCount) {
			this.start = ((this.totalCount - 1) / this.limit * this.limit);
		}
	}

	public final void setPgNumber(int pgNumber) {
		if (pgNumber < 1) {
			pgNumber = 1;
		}
		this.start = ((pgNumber - 1) * this.limit);
	}

	public final int getPgNumber() {
		return this.start / this.limit + 1;
	}

	public final int getEnd() {
		return this.start + this.limit;
	}

	public final int getStart() {
		return this.start;
	}

	public final void setStart(int start) {
		this.start = start;
	}

	public final int getLimit() {
		return this.limit;
	}

	public final void setLimit(int limit) {
		this.limit = limit;
	}

	public final boolean isNeedCount() {
		return this.needCount;
	}

	public final void setNeedCount(boolean needCount) {
		this.needCount = needCount;
	}

	public final String getSort() {
		return this.sort;
	}

	public final void setSort(String sort) {
		this.sort = sort;
	}

	public final String getDir() {
		return this.dir;
	}

	public final void setDir(String dir) {
		this.dir = dir;
	}
	
}
